<template>
  <div>
    <el-upload
      class="upload-demo"
      ref="upload"
      action="http://127.0.0.1:8081/backstage/video/uploadVideo"
      name="file"
      :on-preview="handlePreview"
      :on-remove="handleRemove"
      :file="file">
      <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
      <el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload">上传到服务器</el-button>
    </el-upload>
  </div>
</template>

<script>
export default {
  name: 'VideoUpload',
  data () {
    return {
      filePath: '',
      file: ''
    }
  },
  methods: {
    submitUpload () {
      this.$http('/api/backstage/video/uploadVideo', this.file).then(res => {
        console.log(res)
      })
    },
    handleRemove (file, fileList) {
      console.log(file, fileList)
    },
    handlePreview (file) {
      this.file = file
      // console.log(file)
    }
  }
}
</script>

<style scoped>

</style>
